import java.text.NumberFormat;
import java.util.Locale;

public class Account {
        private long soTK;
        private String tenTK;
        private double soTien;
        
        private final double LAISUAT = 0.02;
        public Account(){
                soTK=0;
                tenTK=null;
                soTien=0;
        }
        
        public Account(long sotk, String tentk, double sotien){
                this.soTK = sotk;
                this.tenTK = tentk;
                this.soTien = sotien;
        }
        
        public Account (long sotk, String tentk){
        	this.soTK = sotk;
        	this.tenTK = tentk;
        	this.soTien = 100;
        }
        
        public long SoTK(){
                return soTK;
        }
        
        public void SoTK(long sotk){
                this.soTK = sotk;
        }
        
        public String TenTK(){
                return tenTK;
        }
        
        public void TenTK(String tentk){
                this.tenTK = tentk;
        }
        
        public double SoTien(){
                return soTien;
        }
        
        public void SoTien(double sotien){
                this.soTien = sotien;
        }
        
        Locale loc = Locale.CANADA;
        NumberFormat nf= NumberFormat.getCurrencyInstance(loc);
        
        public void ToString(){ 
                System.out.println("So TK: " + String.valueOf(soTK));
                System.out.println("Ten TK: " + tenTK);
                System.out.println("So tien: " + nf.format(soTien));
        }
        
        public void NapTien(double soTienNap){
        	this.soTien += soTienNap;
        	System.out.println("Ban da nap vao tai khoan so tien la: " + nf.format(soTienNap));
        	System.out.println("Tong so tien hien tai trong tai khoan la: " + nf.format(soTien));
        }
        
        public void RutTien(double soTienRut){
        	double phi = 5, temp = 0;
        	temp = this.soTien - (soTienRut + phi);
        	if(temp >= 100){
        		this.soTien -= (soTienRut + phi);
        		System.out.println("Ban da rut tu tai khoan so tien la: " + nf.format(soTienRut));
            	System.out.println("Tong so tien hien tai trong tai khoan la: " + nf.format(soTien));
        	}
        	else{
        		System.out.println("So tien hien tai trong tai khoan khong du de rut !");
        	}		      	
        }
        
        public void DaoHan(){
        	this.soTien += this.soTien * LAISUAT;
        	System.out.println("Tong so tien hien tai trong tai khoan la: " + nf.format(soTien));
        }
        
        public void ChuyenKhoan(Account sotkNhan, double sotienchuyen){
        	double temp =0;
        	temp = this.soTien - sotienchuyen;
        	if(temp >= 100){
        		this.soTien -= sotienchuyen;
        		sotkNhan.soTien += sotienchuyen;
        		System.out.println("Ban da chuyen so tien la: " + nf.format(sotienchuyen));
            	System.out.println("Tong so tien hien tai trong tai khoan la: " + nf.format(this.soTien));
        	}
        	else{
        		System.out.println("So tien hien tai trong tai khoan khong du de thuc hien giao dich !");
        	}	
        }
        
        public static void main(String[] args) {
                // TODO Auto-generated method stub
                Account acc1 = new Account(615105057, "nhungvu", 1000000);
                Account acc2 = new Account(615105046, "mainguyen",900000);
                acc2.NapTien(500);
                acc2.ChuyenKhoan(acc1, 300);
                acc1.ToString();
                acc2.ToString();
        }
}
